<template>
	<view class="dAddress-wrap">
		<mescroll-body ref="mescrollRef" @up="getDealerAddress" @init="mescrollInit" :up="upOption"
		 @down="downCallback">
		 <view class="dAddress-item" v-for="(item,index) in list" :key="index" @tap="chooseAddress(item)">
			<!-- <view class="avatar-box">
				<image :src="imgSrc + item.imgReuri" /> 
			 </view> -->
			 <view class="address-box">
				 <view class="user-info">
					 <text class="user-name">{{item.pickupName}}</text>
					 <text class="user-tel">{{item.pickupMobile}}</text>
				 </view>
				 <view class="address-info">{{item.addressDet}}</view>
			 </view>
			<!-- <view class="edit-box"><i class="iconfont iconbianji"></i></view> -->
		 </view>
		 </mescroll-body>
		 <tui-modal></tui-modal>
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				dealerId:'',
				list:[],
				upOption: {
					page: {
						size: 10 // 每页数据的数量,默认10
					},
					noMoreSize: 5,
				},
			}
		},
		onLoad(options) {
			// #ifdef H5
			   this.$wechat.noShare();
			// #endif
			this.dealerId=options.dealerId;
		},
		methods: {
			getDealerAddress(page) {//经销商地址列表取得
				let params = {
					current: page.num,
					pageSize: page.size,
					dealerId:this.dealerId,
				}
				this.$http.getDealerAddress(params).then((res) => {
					if (res.status === 0) {
						let curPageData = res.data.records;
						this.mescroll.endSuccess(res.data.records.length);
						if (page.num == 1) {
							this.list = []
						};
						this.list = this.list.concat(curPageData);
					}
				})
			},
			//选择地址
			chooseAddress(item){
				let address = JSON.stringify(item)
				uni.setStorageSync('pointAddress', address)
				uni.navigateBack()
			},
		}
	}
</script>

<style lang="scss">
	.dAddress-wrap{
		width: 100%;
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom); 
		.dAddress-item{
			width: 100%;
			padding:20rpx 32rpx 30rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			background-color: #fff;
			margin-top:16rpx;
			// .avatar-box{
			// 	width: 90rpx;
			// 	height: 90rpx;
			// 	border-radius: 50%;
			// 	margin-right: 16rpx;
			// 	background-color: #eee;
			// 	image{
			// 		width:90rpx;
			// 		height: 90rpx;
			// 	}
			// }
			.address-box{
				color:#111;
				flex:1;
				font-size:28rpx ;
				.user-info{
					line-height: 50rpx;
					.user-name{
						font-size:32rpx ;
						margin-right: 14rpx;
					}
					.user-tel{
						color:#999;
						font-size:26rpx ;
					}
				}
				.address-info{}
			}
			.edit-box{
				width:28rpx;
				margin-left: 40rpx;
				color:#999
			}
		}
	}
</style>
